# -*- coding: utf-8 -*-
import math


# 实现整除运算
def div(x, y):
    return int(round(x) / round(y))
    # return $cal2('x','x',p_div,x,y);


def DF2DHMS(F):
    df = F
    day = math.floor(df)
    hour = math.floor((df - day) * 24)
    minute = math.floor((df - day - hour / 24) * 1440)
    sec = (df - day - hour / 24 - minute / 1440) * 86400
    return [day, hour, minute, sec]


MJD = 2457454.0
DJMIN = -68569.5
DJMAX = 1e9

DJ1 = 2400000.5
DJ2 = MJD
DJ = DJ1 + DJ2
D1 = ''
D2 = ''
J = ''
JD = ''
if DJ < DJMIN or DJ > DJMAX:

    J = -1
    print
    u'无效的日期: ' + MJD
    print
    J
else:
    J = 0
    if (DJ1 >= DJ2):
        D1 = DJ1
        D2 = DJ2
    else:
        D1 = DJ2
        D2 = DJ1
    D2 = D2 - 0.5
    F1 = D1 % 1.0
    F2 = D2 % 1.0
    F = (F1 + F2) % 1.0
    if (F < 0): F = F + 1.0
    D = round(D1 - F1) + round(D2 - F2) + round(F1 + F2 - F)
    JD = round(D) + 1
    L = JD + 68569
    N = div(4 * L, 146097)
    L = L - div((146097 * N + 3), 4)
    I = div(4000 * (L + 1), 1461001)
    L = L - div(1461 * I, 4) + 31
    K = div(80 * L, 2447)
    ID = L - div(2447 * K, 80)
    L = div(K, 11)

    IM = K + 2 - 12 * L
    IY = 100 * (N - 49) + I + L
    FD = DF2DHMS(F)
    print(MJD, '对应日期为', [IY, IM, int(ID), int(FD[1]), int(FD[2]), FD[3]])
